iT邦幫忙

2021 iThome 鐵人賽

DAY 5
0

After the previous 2 articles of CSS basic introducttion, let's talk about 5 Types of CSS Selector today...

1. Tag Name Selector

body{
	font-size:16;font-family:"Arial"
}
h3{
	font-size:24;text-decoration:underline;
}

2. Class Selector

  • Add a “dot” before the class. Also, we can connect a specific tag before the class if we want it to be the exclusive use of the tag.
div.content{
	padding:10px;border:1px dashed #888888;
}

https://ithelp.ithome.com.tw/upload/images/20210905/20130362jTl2JN3X1R.png

3. id Selector

  • Add a “#” before the id
#btn{
	border:1px solid #888888;
	background-color:#ffffff;padding:5px;
}

4. Pseudo-classes Selector

  • Often used with other selectors
  • Example1. #:hover--for button clicking design
#btn:hover{
	background-color:#888888;
}

https://ithelp.ithome.com.tw/upload/images/20210905/20130362QMBmsmsP92.png

  • Example2. #:focus--for getting cursor’s focus
input:focus{
	border:2px solid #ff0000;
}

https://ithelp.ithome.com.tw/upload/images/20210905/201303622nkigxoRVI.png

5. Cascading Selector

  • Often used with other selectors
.content1 a{
	color:#0000ff;
}
.content2 a{
	color:#008800;
}

https://ithelp.ithome.com.tw/upload/images/20210905/20130362Y9Mhrv4DQR.png


Music of Today: Peaches covered by 吱吱郭芝吟ChihChih

Yes


Like/Share/Follow

If you guys find this article helpful, please kindly do the writer a favor — LIKE this article./images/emoticon/emoticon12.gif
Feel free to comment and share your ideas below to learn together!


上一篇
#4 CSS Box Model, Selector, Absolute/Relative Position
下一篇
#6 CSS Table x Stock Price
系列文
Learn & Play JavaScript -- Entry-Level Front-End Web Development30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言